import request, { axiosOptions, axiosRequest } from '@/utils/request'
import { praseStrEmpty } from "@/utils/ruoyi";

// 查询管理员列表
export function listUser(query) {
  let options = axiosOptions('get')
  return axiosRequest('/admin/getAdmins',query,options);
}

/**
 * 新增或编辑用户
 * @param admin
 * @returns {Promise<unknown>}
 */
export function addOrEditAdmin(admin){
  let options = axiosOptions(null,"application/json");
  return axiosRequest("admin/addOrEdit",JSON.stringify(admin),options)
}

//根据id批量删除用户，暂时不用
export function deleteAdminByIds(ids){
  let options = axiosOptions(null,"application/json");
  return axiosRequest("/admin/deleteByIds",JSON.stringify({'deleteIds':ids}),options)
}

//根据id删除
export function deleteAdmin(id){
  return axiosRequest("/admin/deleteById",id)
}


// 用户密码重置
export function resetUserPwd(admin) {
  return axiosRequest("/admin/resetPassWord",admin)
}

// 用户状态修改
export function changeAdminLocked(admin) {
  return axiosRequest("/admin/changeAdminLocked",admin)
}

// 查询用户个人信息
export function getAdminProfile() {
  let option = axiosOptions('get');
  return axiosRequest('/admin/getInfo',null,option);
}

// 修改用户个人信息
export function updateAdminProfile(data) {
  return axiosRequest('/admin/updateMyself',data)
}

// 用户密码重置
export function updateUserPwd(oldPassword, newPassword) {
  const data = {
    oldPassword,
    newPassword
  }
  return axiosRequest('admin/updateMyselfPassword',data)
}


